<?
$task_plan=  _select_unique_result("select * from task_plan where `ID_pro`='$_GET[project]'");
if(!isset($task_plan['ID_task'])){
    $insert=  _insert('task_plan',array('id_pro'=>$_GET['project']));
    $task_plan=  _select_unique_result("select * from task_plan where `ID_pro`='$_GET[project]'");
}
$task_plan_detail=  _select_arr("select * from task_plan_detail where ID_task=$task_plan[ID_task]");
?>

<h2 class="judul">Task Plan</h2>
<div class="content">
    <form action="?page=quality_plan/file_upload&id_task=<?=$task_plan['ID_task']?>">
        <div class="data-input">
            <fieldset>
                <legend>Attach File</legend>
                <label>File</label><div class="button"><a href="" class="download-btn tipsy-north" title="download">Download</a></div>
                <label>Edit File</label><input type="file" name="file"/>
            </fieldset>
        </div>
    </form>
    <a href="index_form.php?page=task_plan/tp-detail-add&id_task=<?=$task_plan['ID_task']?>" class="uibutton" 
        rel="add-dialog" target="ajax-modal" header="Tambah Task Plan" 
        original-title="Tambah Task Plan">+ Tambah</a>
    <table class="data-table" width="100%">
        <tr>
            <th>Task-ID</th>
            <th>Task Name</th>
            <th>Duration</th>
            <th>Previous Task</th>
            <th>Next Task</th>
            <th>Aksi</th>
        </tr>
        <?foreach($task_plan_detail as $detail):?>
        <tr>
            <td><?=$detail['ID_tp_detail']?></td>
            <td><?=$detail['name']?></td>
            <td><?=$detail['duration']?></td>
            <td><?=$detail['prev']?></td>
            <td><?=$detail['next']?></td>
            <td class="button">
                <a href="index_form.php?page=task_plan/tp-detail-edit&id=<?=$detail['ID_tp_detail']?>" class="edit-btn tipsy south" 
                       rel="add-dialog" target="ajax-modal" header="Edit Task Plan" 
                       title="Edit" original-title="Edit Quality Plan">edit</a>
                <a href="index_form.php?page=task_plan/task-detail-delete&id=<?= $detail['ID_tp_detail'] ?>" class="delete-btn tipsy south"
                    onClick="return confirm('Are you sure to delete this data?')" title="Delete Data">delete</a>
            </td>
        </tr>
        <?endforeach;?>
    </table>
</div>